﻿Imports DevComponents.DotNetBar.SuperGrid
Imports DevComponents.DotNetBar.SuperGrid.Style
Public Class USERPOLICY
    Dim connect As CONDB = CONDB.NewConnection()
    Dim selectEmpRow As Integer = -1
    Dim PROVIDER_MASPROVIDER As New PROVIDERSCLASS

    Private Sub USERPOLICY_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        queryUsergroupGrid()

        PROVIDER_MASPROVIDER.GETHOSEM(CInt(main.txtUserRequest.Text.Trim), Convert.ToString(Me.Tag))
    End Sub

    Public Sub queryUsergroupGrid()
        Dim userGroupGrid As DataTable = connect.GetTable("SELECT `EMPID` AS 'รหัสพนักงาน', `PROVIDER` AS 'รหัสผู้ให้บริการ', CONCAT_WS(' ', `NAME`, `LNAME`) AS 'ชื่อ-สกุล', `STATUS` AS 'สถานะการเปิดใช้งาน', `F_CASH` AS 'F_CASH' FROM hospemp")
        userGrid.PrimaryGrid.DataSource = userGroupGrid
    End Sub

    Private Sub userGrid_CellClick(sender As Object, e As GridCellClickEventArgs) Handles userGrid.CellClick
        If e.MouseEventArgs.Button = Windows.Forms.MouseButtons.Right Then
            selectEmpRow = e.GridCell.RowIndex
        End If
    End Sub

    Private Sub givePolicy_Click(sender As Object, e As EventArgs) Handles givePolicy.Click
        Dim empid As String = CType(userGrid.PrimaryGrid.Rows(selectEmpRow), GridRow).Cells("รหัสพนักงาน").Value

        Dim CMSPHERE As New USERPOLICYEDIT(empid)
        Dim resultForm As DialogResult = CMSPHERE.ShowDialog
    End Sub

    Private Sub newUserBtn_Click(sender As Object, e As EventArgs) Handles newUserBtn.Click
        Dim newFOrm As New ADDPROVIDER(PROVIDER_MASPROVIDER.txtusername_tag_)
        Dim resultForm As DialogResult = newFOrm.ShowDialog()

        If resultForm = Windows.Forms.DialogResult.OK Then
            queryUsergroupGrid()
        End If
    End Sub

    
    Private Sub ButtonItem1_Click(sender As Object, e As EventArgs)
        Dim newFOrm As New ADDPROVIDER(PROVIDER_MASPROVIDER.txtusername_tag_)
        Dim resultForm As DialogResult = newFOrm.ShowDialog()

        If resultForm = Windows.Forms.DialogResult.OK Then
            queryUsergroupGrid()
        End If
    End Sub

    Private Sub editHospemp_Click(sender As Object, e As EventArgs) Handles editHospemp.Click
        Dim empid As String = CType(userGrid.PrimaryGrid.Rows(selectEmpRow), GridRow).Cells("รหัสพนักงาน").Value

        Dim newFOrm As New EDITPROVIDER(empid, PROVIDER_MASPROVIDER.txtusername_tag_)
        Dim resultForm As DialogResult = newFOrm.ShowDialog()

        If resultForm = Windows.Forms.DialogResult.OK Then
            queryUsergroupGrid()
        End If
    End Sub

    
End Class